Use a better hash for arcs
authorMatthias Clasen <mclasen@redhat.com>
Sun, 1 May 2016 02:39:26 +0000 (22:39 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 1 May 2016 02:39:58 +0000 (22:39 -0400)
gtk/gtkroundedbox.c

index 67aed7a786ea50b90b8f9eeab912d095d75bce0e..a6d9019b4d5e7220774b98b833b03eda67c85f60 100644 (file)
@@ -228,10 +228,25 @@ typedef struct {
   gboolean negative;
 } Arc;
 
+static inline guint
+mem_hash (gconstpointer v, gint len)
+{
+  const signed char *p;
+  const signed char *end;
+  guint32 h = 5381;
+
+  p = v;
+  end = p + len;
+  for (;  p < end; p++)
+    h = (h << 5) + h + *p;
+
+  return h;
+}
+
 static guint
 arc_path_hash (Arc *arc)
 {
-  return g_double_hash (&arc->angle1) ^ g_double_hash (&arc->angle2) ^ arc->negative;
+  return mem_hash ((gconstpointer)arc, sizeof (Arc));
 }
 
 static gboolean